package com.cy.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cy.entity.Meetingroom;
import com.cy.entity.MeetingroomExample;
import com.cy.mapper.MeetingroomMapper;

@Service
public class MeetingroomService {
	@Autowired
	private MeetingroomMapper mapper;
	public List<Meetingroom> findAllMeetingroom() {
		return mapper.selectByExample(null);
	}
	
	public Meetingroom findMeetingroomById(Integer id) {
		return mapper.selectByPrimaryKey(id);
	}

	
	public List<Meetingroom> findMeetingroomByType(Integer id) {
		MeetingroomExample me = new MeetingroomExample();
		me.createCriteria().andTypeidEqualTo(id);
		return mapper.selectByExample(me);
	}

	public void addMeetroom(Meetingroom mt) {
		mapper.insert(mt);
	}
	
	public void updateMeetroom(Meetingroom room) {
		mapper.updateByPrimaryKey(room);
	}
	
	public void deleteMeetingroom(Integer id) {
		mapper.deleteByPrimaryKey(id);
	}
	
	public List<Meetingroom> findMeetingRoomsByUser() {
		MeetingroomExample me = new MeetingroomExample();
		me.createCriteria().andStatusEqualTo(1);
		return mapper.selectByExample(me);
	}
	
	public List<Meetingroom> findMeetingroomByTypeId(Integer typeId) {
		MeetingroomExample me = new MeetingroomExample();
		me.createCriteria().andTypeidEqualTo(typeId);
		return mapper.selectByExample(me);
	}
}
